<script type="text/javascript">
function validate_form() {
    <?php
        if(count($this->language) > 0) :
            foreach($this->language as $value) :
    ?>
    if($('#tabs-<?php echo $value['locale'] ?>').hasClass('ui-tabs-hide') == false) {
        var max = $('#max').val();
        var price = $('#price').val();
        var name_<?php echo $value['locale'] ?> = $('#name-<?php echo $value['locale'] ?>').val();
        var description_<?php echo $value['locale'] ?> = CKEDITOR.instances['description-<?php echo $value['locale'] ?>'].getData();
        var countError = 0;
        if((name_<?php echo $value['locale'] ?>.length < 1) || (name_<?php echo $value['locale'] ?>.length > 100)) {
            $('#errorName-<?php echo $value['locale'] ?>').html('Tên phòng từ 1-100 kí tự');
            countError++;
        }
        else {
            $('#errorName-<?php echo $value['locale'] ?>').html('');
        }
        if(description_<?php echo $value['locale'] ?> == '') {
            $('#errorDescription-<?php echo $value['locale'] ?>').html('Giới thiệu về phòng không được để trống');
            countError++;
        }
        else {
            $('#errorDescription-<?php echo $value['locale'] ?>').html('');
        }
        var reg = /^([0-9]{1,3})$/;
        if(reg.test(max) == false) {
            $('#errorMax').html('Tối đa gồm các kí tự số 0-9 và không quá 3 kí tự');
            countError++;
        }
        else {
            $('#errorMax').html('');
        }
        var reg = /^([0-9]{1,6})$/;
        if(reg.test(price) == false) {
            $('#errorPrice').html('Giá tiền gồm các kí tự số 0-9 và không quá 6 kí tự');
            countError++;
        }
        else {
            $('#errorPrice').html('');
        }
        if(countError > 0) {
            return false;
        }
        else {
            return true;
        }
    }
    <?php
            endforeach;
        endif;
    ?>
};
</script>
<h3 style="margin: 10px 0 0 0; padding:0; text-align: center;">Thêm phòng mới</h3><br />
<div class="content">
<form action="" method="post" onsubmit="return validate_form()">
    <input type="hidden" name="type" value="<?php echo $this->room['type']; ?>" />
    <input type="hidden" name="hotel_id" value="<?php echo $this->room['hotel_id']; ?>" />
    <div id="tabs">
        <ul>
            <?php
                if(count($this->language) > 0) :
                    foreach($this->language as $value) :
            ?>
                <li><a href="#tabs-<?php echo $value['locale']; ?>"><?php echo $value['name']; ?></a></li>
            <?php
                    endforeach;
                endif;
            ?>
        </ul>
        
        <?php
            if(count($this->language) > 0) :
                foreach($this->language as $value) :
        ?>
        <div id="tabs-<?php echo $value['locale']; ?>">
            <table class="table">
                <tr>
                    <td class="td1"><?php echo $this->formLabel('name-'.$value['locale'],'Tên phòng'); ?>&nbsp;<span class="error-msg">*</span></td>
                    <td class="td2"><?php echo $this->formText('name-'.$value['locale'],null,array('class'=>'input','style'=>'width:295px')); ?></td>
                    <td class="td3" id="errorName-<?php echo $value['locale']; ?>"></td>
                </tr>
                <tr>
                    <td class="td1"><?php echo $this->formLabel('description-'.$value['locale'],'Giới thiệu về phòng'); ?>&nbsp;<span class="error-msg">*</span></td>
                    <td class="td2"><?php echo $this->formTextarea('description-'.$value['locale'],null,array('class'=>'ckeditor','style'=>'height: 100px;')); ?></td>
                    <td class="td3" id="errorDescription-<?php echo $value['locale']; ?>"></td>
                </tr>
            </table>
        </div>
        <?php
                endforeach;
            endif;
        ?>
        
        <table class="table">
            <tr>
                <td class="td1"><?php echo $this->formLabel('max', 'Tối đa'); ?></td>
                <td class="td2">
                    <?php echo $this->formText('max', null, array('class'=>'input','style'=>'width: 120px;')); ?>
                    người
                </td>
                <td class="td3" id="errorMax"></td>
            </tr>
            <tr>
                <td class="td1"><?php echo $this->formLabel('price', 'Giá tiền'); ?></td>
                <td class="td2">
                    <?php echo $this->formText('price', null, array('class'=>'input','style'=>'width: 120px;')); ?>
                    000đ
                </td>
                <td class="td3" id="errorPrice"></td>
            </tr>
            <tr>
                <td class="td1">&nbsp;</td>
                <td class="td2" colspan="2">
                    <?php echo $this->formSubmit('submit','Tạo mới',array('class'=>'button')); ?>
                    <?php echo $this->formReset('reset','Nhập lại',array('class'=>'button')); ?>
                    <a href="<?php echo $this->baseUrl('admincp/room/index?type='.$this->room['type'].'&hotel_id='.$this->room['hotel_id']); ?>" class="button" style="color: #fff; height: 26px;">Quay lại</a>
                </td>
                <td class="td3"></td>
            </tr>
        </table>
    </div>
</form>
</div>